Skip to content

[libcu++] Implement P3793R2 Better Shifting (without SIMD)#9993

Merged
davebayer merged 5 commits into
NVIDIA:mainfrom
davebayer:better_shifting
Jul 21, 2026
Merged

[libcu++] Implement P3793R2 Better Shifting (without SIMD)#9993
davebayer merged 5 commits into
NVIDIA:mainfrom
davebayer:better_shifting

Conversation

@davebayer

@davebayer davebayer commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This PR implement P3793R2 Better Shifting. I've omitted the simd support, should be done in a separate PR.

@davebayer
davebayer requested a review from a team as a code owner July 17, 2026 12:56
@davebayer
davebayer requested a review from wmaxey July 17, 2026 12:56
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 17, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d408be7f-4b7c-406e-9f9b-5bc585cd9353

📥 Commits

Reviewing files that changed from the base of the PR and between a446de5 and bb00c36.

📒 Files selected for processing (2)
  • libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shl.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shr.pass.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shl.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shr.pass.cpp

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added cuda::std::shl and cuda::std::shr constexpr integer shift utilities, including support for signed/unsigned operands and negative shift counts.
    • Included the new headers in the cuda/std/bit umbrella.
  • Tests
    • Added pass tests covering shl/shr across many integer types and edge-case shift values.
    • Refined the test DoNotOptimize barrier logic to use separate device vs. host handling.
  • Documentation
    • Updated the cuda/std/bit header copyright year.

Walkthrough

Changes

Adds cuda::std::shl and cuda::std::shr with constexpr integer shifting, signed-shift normalization, width clamping, and CUDA PTX dispatch. Exposes both APIs through cuda/std/bit and adds host/device tests.

Integer shift utilities

Layer / File(s) Summary
Shift API implementations
libcudacxx/include/cuda/std/__bit/*, libcudacxx/include/cuda/std/bit
Adds constrained shl and shr functions with constexpr/noexcept behavior, signed-shift handling, out-of-range results, device PTX paths, and umbrella-header exports.
shl validation
libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shl.pass.cpp
Tests positive and negative shifts, width boundaries, constant evaluation, noexcept/type properties, and signed, unsigned, and optional 128-bit integer combinations.
shr validation and device barriers
libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shr.pass.cpp, libcudacxx/test/support/test_macros.h
Tests positive and negative shr behavior across integer types and architectures, while separating device and host DoNotOptimize barriers.

Possibly related PRs

  • NVIDIA/cccl#10037: Updates the same DoNotOptimize implementation with device/host-specific barriers.

Suggested labels: libcu++

Suggested reviewers: wmaxey, jacobfaib


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 487bc115-c3d6-4a80-845a-898abd27190e

📥 Commits

Reviewing files that changed from the base of the PR and between 81279b3 and 247d04d.

📒 Files selected for processing (6)
  • libcudacxx/include/cuda/std/__bit/shl.h
  • libcudacxx/include/cuda/std/__bit/shr.h
  • libcudacxx/include/cuda/std/bit
  • libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shl.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shr.pass.cpp
  • libcudacxx/test/support/test_macros.h

Comment thread libcudacxx/include/cuda/std/__bit/shl.h Outdated
@davebayer davebayer changed the title [libcu++] Implement P3793R2 Better Shifting [libcu++] Implement P3793R2 Better Shifting (without SIMD) Jul 17, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
libcudacxx/test/support/test_macros.h (1)

112-112: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Make the pointer object const. ptr is not reassigned; use a top-level const while retaining its volatile qualification for the assembly operand.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: edbeeff7-f119-4e50-a24a-968539124e5c

📥 Commits

Reviewing files that changed from the base of the PR and between d62708c and bd57e62.

📒 Files selected for processing (1)
  • libcudacxx/test/support/test_macros.h

Comment thread libcudacxx/test/support/test_macros.h
Comment thread libcudacxx/include/cuda/std/__bit/shl.h
Comment thread libcudacxx/include/cuda/std/__bit/shl.h Outdated
Comment thread libcudacxx/include/cuda/std/__bit/shl.h
Comment thread libcudacxx/include/cuda/std/__bit/shr.h Outdated
Comment thread libcudacxx/include/cuda/std/__bit/shr.h Outdated
Comment thread libcudacxx/include/cuda/std/__bit/shr.h Outdated
Comment thread libcudacxx/include/cuda/std/bit
Comment thread libcudacxx/test/support/test_macros.h
Comment thread libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shl.pass.cpp
@github-actions

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fda5c3a1-5f14-46b1-be51-1d514f52635c

📥 Commits

Reviewing files that changed from the base of the PR and between bd57e62 and a446de5.

📒 Files selected for processing (6)
  • libcudacxx/include/cuda/std/__bit/shl.h
  • libcudacxx/include/cuda/std/__bit/shr.h
  • libcudacxx/include/cuda/std/bit
  • libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shl.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shr.pass.cpp
  • libcudacxx/test/support/test_macros.h
🚧 Files skipped from review as they are similar to previous changes (4)
  • libcudacxx/include/cuda/std/bit
  • libcudacxx/include/cuda/std/__bit/shr.h
  • libcudacxx/test/support/test_macros.h
  • libcudacxx/include/cuda/std/__bit/shl.h

Comment thread libcudacxx/test/libcudacxx/std/numerics/bit/bit.shift/shl.pass.cpp
@davebayer davebayer linked an issue Jul 21, 2026 that may be closed by this pull request
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 4h 36m: Pass: 100%/120 | Total: 4d 11h | Max: 3h 19m | Hits: 50%/2050801

See results here.

@davebayer
davebayer requested a review from fbusato July 21, 2026 17:41
@davebayer
davebayer merged commit f75bc70 into NVIDIA:main Jul 21, 2026
280 of 285 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[FEA]: Non-SIMD part of P3793R2

2 participants